<%@page import="cn.jhc.dao.TitleDAO"%>
<%@page import="cn.jhc.bean.HfmsgBean"%>
<%@page import="cn.jhc.bean.UserBean"%>
<%@page import="cn.jhc.bean.AllHfmsgBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@page import="cn.jhc.dao.MsgDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="cn.jhc.bean.UserBean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="FCK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="./css/msg.css"></link>
<title>留言板</title>
<script language="javascript">
function fsubmit(obj){
obj.submit();
}
function MM_popupMsg(msg) {
	alert(msg);
}
function checkSubmit(){
	if(ture==checkSubmitFlg){
		document.form.submit();
		checkSubmitFlg=flase;
	}else{
		alert("您已经提交了表单，请不要重复提交！");
	}
}
</script> 
</head>
<body>
	<%
		int CurrentPage = 1; //初始值,第一页
		int intPageCount; //全部的也数
		if (request.getParameter("page") != null) //判断传过来的数据
			CurrentPage = Integer.parseInt(request.getParameter("page")); //装换为整形
		if (CurrentPage < 1) //使初始值不小于一，始终是第一页
			CurrentPage = 1;
	%>
	<div id="wrapper">

		<%
			String id = request.getParameter("id");
			int Id = Integer.parseInt(id);
			HfmsgBean m = new HfmsgBean();
			MsgDao dao = new MsgDao();
			dao.setCon(ConnectionFactory.getConnection());
			m = dao.getoneMessages(Id);
			request.setAttribute("title", m);
		%>
		<%
			HfmsgBean t = new HfmsgBean();
			MsgDao dao3 = new MsgDao();
			dao3.setCon(ConnectionFactory.getConnection());
			t = dao3.getonetopMessages(Id);
			request.setAttribute("top", t);
		%>
		<%
			dao.setCon(ConnectionFactory.getConnection());
			ArrayList<AllHfmsgBean> h = new ArrayList<AllHfmsgBean>();
			h = dao.getHFMessages(Id, CurrentPage);
			request.setAttribute("liuyan", h);
		%>
		<%
			MsgDao dao2 = new MsgDao();
			dao2.setCon(ConnectionFactory.getConnection());
			intPageCount = dao2.getHfCount(Id);
			if (intPageCount == 0) {
				CurrentPage = 1;
				intPageCount = 1;
			} else {
				if (CurrentPage > intPageCount)
					CurrentPage = intPageCount;
			}
		%>
		<jsp:include page="./header.jsp"></jsp:include>
		<div id="address">
			<a>当前位置： 讨论区 > 灌水区</a>
		</div>
		<div id="wrapperdown">
			<div id="allmessage">
			<div id="top_message">
				<div class="name" align="left"><a>${requestScope.title.displayname}${requestScope.top.displayname}:</a></div>
				<div class="title" align="left"><a>${requestScope.title.title}${requestScope.top.title}</a></div>
				<div class="content" align="left"><a>　　${requestScope.title.content}${requestScope.top.content}</a></div>
				<div class="date" align="right"><a>${requestScope.title.date}${requestScope.top.date}</a></div>
			</div>
			<%int i=0; %>
			<c:forEach var="liuyan" items="${requestScope.liuyan}">
				<%	i++;
					if(i%2==1){
				%>
				<div id="triangle"></div>
				<div id="down_message">
					<div class="msg_lou" align="right"><a><%=i%>#</a></div>
					<div class="msg_name" align="left"><a>${liuyan.displayname}:</a></div>
					<div class="msg_content" align="left"><a>${liuyan.content}</a></div>
					<div class="msg_date" align="right"><a>${liuyan.date}</a></div>
				</div>
				<%}else{%>
				<div id="triangle2"></div>
				<div id="down_message2">
					<div class="msg_lou" align="right"><a><%=i%>#</a></div>
					<div class="msg_name" align="left"><a>${liuyan.displayname}:</a></div>
					<div class="msg_content" align="left"><a>${liuyan.content}</a></div>
					<div class="msg_date" align="right"><a>${liuyan.date}</a></div>
				</div>
				<%}%>
			</c:forEach>
			</div>
			<div id="pagebg"></div>
			<div id="page" align="right">
				<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
				</a> <a href="showmessages.jsp?page=<%=1%>&id=${requestScope.title.id}${requestScope.top.id}">首页</a>
				<%
					if (CurrentPage > 1) {
				%>
				<a
					href="showmessages.jsp?page=<%=CurrentPage-1%>&id=${requestScope.title.id}${requestScope.top.id}">上一页</a>
				<%
					} else {
				%>
				上一页
				<%
					}
				%>
				<%
					if (CurrentPage >= intPageCount) {
				%>
				下一页
				<%
					} else {
				%>
				<a
					href="showmessages.jsp?page=<%=CurrentPage+1%>&id=${requestScope.title.id}${requestScope.top.id}">下一页</a>
				<%
					}
				%>
				<a
					href="showmessages.jsp?page=<%=intPageCount%>&id=${requestScope.title.id}${requestScope.top.id}">末页</a>
			</div>
			<div id="submit">
			<div id="statement"><a>声明：</a><a>请发表健康的言论，发现不良发言，会扣除积分，严重者一律直接删号！</a></div>
				<form name="form" method="post"
					action="./addHfmessage.do?titleid=${requestScope.title.id}${requestScope.top.id}&getb=/showmessages.jsp?id=${requestScope.title.id}${requestScope.top.id}">
					<p>
						<FCK:editor id="content" basePath="./fckeditor/"
							width="900"
							imageBrowserURL="../filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
							linkBrowserURL="../filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
							flashBrowserURL="../filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
							imageUploadURL="../filemanager/upload/simpleuploader?Type=Image"
							linkUploadURL="../filemanager/upload/simpleuploader?Type=File"
							flashUploadURL="../filemanager/upload/simpleuploader?Type=Flash">
							发表前请登录...
						</FCK:editor>
					</p>
						<input type="hidden" name="getb"
							value="/showmessages.jsp?titleid=${requestScope.title.id}">
						<div id="tijiao"><a href="javascript:fsubmit(document.form);" onclick="checkSubmit();"><img src="images/button.jpg" width="100"></a></div>
				</form>
			</div>
		</div>
		<div id="line2"></div>
		<div id="copyright">
			<a>版权所有:蓝调吉他社 </a><a>| </a>
			<div id="admin">
				<a href="houtai_index.jsp">管理员登录</a>
			</div>
		</div>
	</div>
</body>
</html>